package e2e

import (
	classModel "github.com/lab-online/internal/class/infra/model"
	courseModel "github.com/lab-online/internal/course/infra/model"
	"github.com/lab-online/internal/user/entity"
	userModel "github.com/lab-online/internal/user/infra/model"
	"github.com/lab-online/pkg/auth"
	baseModel "github.com/lab-online/pkg/model"
)

func (ctx *context) utilsCreateClass(id uint, name string, teacher string, courseID uint) {
	ctx.Database.Save(&classModel.Class{
		BaseModel:   baseModel.BaseModel{ID: id},
		Name:        name,
		Description: "e2e测试样例",
		Teacher:     teacher,
		CourseID:    courseID,
	})
}

func (ctx *context) utilsCreateStudent(classID uint, username string) {
	ctx.Database.Save(&classModel.Student{
		Username: username,
		ClassID:  classID,
	})
}

func (ctx *context) utilsCreateUser(username string, role auth.Role) {
	hashedPwd, _ := entity.HashPassword("AD%%^U44BRY")
	ctx.Database.Save(&userModel.User{
		Username: username,
		Role:     uint8(role),
		Password: hashedPwd,
	})
}

func (ctx *context) utilsCreateCourse(id uint, name string) {
	ctx.Database.Save(&courseModel.Course{
		BaseModel:   baseModel.BaseModel{ID: id},
		Name:        name,
		Description: "e2e测试样例",
	})
}
